# _*_ coding utf-8 _*_
# FILENAME：.py
# DESCRIPTION: 
# AUTH: 
# DATE: 2022/6/82:45 下午
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *

from components.BaseMainWindow import BaseMainWindow
from components.SelectFactoryComponent import SelectFactoryComponent
from components.SelectProductionLineComponent import SelectProductionLineComponent
from views.require.selectBom import SelectBom
from views.require.selectDelayTime import SelectDelayTime
from views.require.selectParts import SelectParts

from views.require.selectProduceQueue import SelectProduceQueue
from views.require.selectProduceSpeed import SelectProduceSpeed


class OrderPlanForm(BaseMainWindow):

    __weldId = None
    __paintId = None
    __summaryId = None


    def __init__(self):
        super(OrderPlanForm, self).__init__()
        self.setupUi(self)

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(550, 400)
        MainWindow.setWindowTitle("零件需求汇总")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")

        '''水平布局'''
        hbox = QHBoxLayout()
        self.save_btn = QPushButton()
        self.save_btn.setText('运算')
        self.save_btn.setFixedWidth(80)
        # self.save_btn.clicked.connect(lambda: self.save_btn_click(parent))

        self.cancel_btn = QPushButton()
        self.cancel_btn.setText('取消')
        self.cancel_btn.setFixedWidth(80)
        # self.cancel_btn.clicked.connect(self.cancel_btn_click)
        hbox.addStretch(1)  # 占位
        hbox.addWidget(self.save_btn)
        hbox.addWidget(self.cancel_btn)
        hbox.addStretch(1)  # 占位
        btnPanelWidget = QWidget()
        btnPanelWidget.setLayout(hbox)

        '''表单布局'''
        self.fac_lab = QLabel()
        self.fac_lab.setText('工厂：')
        self.fac_combox = SelectFactoryComponent()
        self.fac_combox.setObjectName("fac_combox")
        self.fac_combox.setPlaceholderText('请选择工厂')
        self.fac_combox.setCurrentIndex(0)

        self.weld_lab = QLabel()
        self.weld_lab.setText('焊装零件：')
        self.weld_edit = QLineEdit()
        self.weld_btn = QPushButton("选择")
        self.weld_btn.clicked.connect(self.openSelectParts(1))

        self.paint_lab = QLabel()
        self.paint_lab.setText('涂装零件：')
        self.paint_edit = QLineEdit()
        self.paint_btn = QPushButton("选择")
        self.paint_btn.clicked.connect(self.openSelectParts(2))

        self.summary_lab = QLabel()
        self.summary_lab.setText('总装零件：')
        self.summary_edit = QLineEdit()
        self.summary_btn = QPushButton("选择")
        self.summary_btn.clicked.connect(self.openSelectParts(3))


        #  布局
        gbox = QGridLayout()
        gbox.addWidget(self.fac_lab, 0, 0, 1, 1)
        gbox.addWidget(self.fac_combox, 0, 1, 1, 1)

        gbox.addWidget(self.weld_lab, 1, 0, 1, 1)
        gbox.addWidget(self.weld_edit, 1, 1, 1, 1)
        gbox.addWidget(self.weld_btn, 1, 2, 1, 1)

        gbox.addWidget(self.paint_lab, 2, 0, 1, 1)
        gbox.addWidget(self.paint_edit, 2, 1, 1, 1)
        gbox.addWidget(self.paint_btn, 2, 2, 1, 1)

        gbox.addWidget(self.summary_lab, 3, 0, 1, 1)
        gbox.addWidget(self.summary_edit, 3, 1, 1, 1)
        gbox.addWidget(self.summary_btn, 3, 2, 1, 1)

        # gbox.setColumnStretch(3, 1)

        gbox.addWidget(btnPanelWidget, 4, 0, 1, 3)

        vbox = QVBoxLayout()
        vbox.addLayout(gbox)
        vbox.addLayout(hbox)

        self.centralwidget.setLayout(vbox)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 550, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        # self.retranslateUi(MainWindow)
        # QtCore.QMetaObject.connectSlotsByName(MainWindow)

    # def retranslateUi(self, MainWindow):
    #     _translate = QtCore.QCoreApplication.translate
    #     MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow1"))

    def openSelectProduceQueue(self):
        self.selectProduceQueue = SelectProduceQueue(self)
        self.selectProduceQueue.show()

    def openSelectProduceSpeed(self):
        self.selectProduceSpeed = SelectProduceSpeed(self)
        self.selectProduceSpeed.show()

    def openSelectBom(self):
        self.selectBom = SelectBom(self)
        self.selectBom.show()

    def openSelectParts(self):
        self.selectParts = SelectParts(self)
        self.selectParts.show()

    def openSelectDelayTime(self):
        self.selectDelayTime = SelectDelayTime(self)
        self.selectDelayTime.show()

    def setProduceQueueId(self, id):
        self.__produceQueueId = id

    def setProduceSpeedId(self, id):
        self.__produceSpeedId = id

    def setBomId(self, id):
        self.__bomId = id

    def setPartsId(self, id):
        self.__partsId = id

    def setDelayTimeId(self, id):
        self.__delayTimeId = id